void game()
{
	int chance = 5;
	int r = 0;
	int guess = 0;
	r = rand() % 100 + 1;
	printf("请猜数字\n");
	next:
	printf("你的机会还有%d次\n", chance);
	scanf("%d", &guess);
	if (guess > r)
	{
		printf("猜大了\n");
		chance--;
		goto next;
	}
	else if (guess < r)
	{
		printf("猜小了\n");
		chance--;
		goto next;
	}
	else
	{
		printf("猜对啦！\n");
	}
	printf("没错，正确答案是%d\n", r);
}
#include<time.h>
#include<stdio.h>


int main()
{
	srand((unsigned int)time(NULL));
	
	again:
	int input = 0;
	printf("接下来进行猜数字游戏，按1开始，按0退出。\n");
	scanf("%d", &input);
	switch (input)
	{
	case 1:
		system("cls");
		game();//猜数字游戏
		break;
	case 0:
		printf("再见！\n");
		break;
	default:
		printf("输入错误，再也不见！\n");
		break;
	}
	if (input == 1)
	{
		goto again;
	}
	return 0;
}
